<extend name="./public/frame.html"/>
<block name="content">
    <!--<form class="layui-form">-->
    <div class="layui-collapse">
        <div class="layui-colla-item" lay-filter="driver">
            <h2 class="layui-colla-title" data-v="driver">提现信息</h2>
            <div class="layui-colla-content layui-show">
                <table class="layui-table layui-form">
                    <volist name="fields" id="vo">
                        <tr>
                            <td>{$vo}</td>
                            <td>
                                <if condition="$key eq 'abnormal_des'">
                                    <ol>
                                        <volist name="$info['abnormal_des']" id="v">
                                            <li>{$v}</li>
                                        </volist>
                                    </ol>
                                    <else/>
                                    {$info[$key]}
                                </if>
                            </td>
                        </tr>
                    </volist>

                    <tr>
                        <td>是否支付失败</td>
                        <td>
                            <input type="checkbox" data-id="" value="2" lay-skin="switch" lay-text="是|否" lay-filter="is_use">
                            <input type="text" name="check_status" id="check_status" value="2" hidden>
                        </td>
                    </tr>
                    <tr>
                        <td>失败原因</td>
                        <td>
                            <textarea name="error_code" id="error_code" placeholder="*失败原因必填" rows="5" cols="80"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="layui-row" style="text-align:center">
            <input type="hidden" id="cash_id" value="{$info['id']}"/>
            <input type="hidden" id="driver_phone" value="{$info['driver_phone']}" />
            <input type="hidden" id="driver_id" value="{$info['driver_id']}" />
            <button class="layui-btn" style="margin-bottom: 22px;" lay-submit="" lay-filter="submit" id="submits">
                确认审核
            </button>
        </div>
    </div>
    <!--</form>-->
    <script>
        layui.use(['layer','form','table','element'], function () {
            var layer = layui.layer,
                table = layui.table,
                form = layui.form;

            //监听启用/停用操作
            form.on('switch(is_use)', function(obj){
                var check = obj.elem;
                var value = obj.value;
                var check_status = $('#check_status');

                switch(value){
                    case '2':
//                        auth.show().children('td').children('textarea').attr('lay-verify','required');
                        $(check).prop('checked',obj.elem.checked).val('9');
                        check_status.val('9');
                        form.render('checkbox');
                        break;
                    case '9':
                        //auth.hide().children('td').children('textarea').attr('lay-verify','');
                        $(check).prop('checked',obj.elem.checked).val('2');
                        check_status.val('2');
                        form.render('checkbox');
                        break;
                    default:
                        break;
                }
            });

            $(document).on('click', '#submits', function () {
//                var remark = $('#remark').val();
//                if (remark == '') {
//                    layer.alert('审核备注不能为空');
//                    return false;
//                }
                var id = $('#cash_id').val();
                var driver_id = $('#driver_id').val();
                var check_status = $('#check_status').val();
                var error_code = $('#error_code').val();
                var driver_phone = $('#driver_phone').val();

                if(error_code == '') {
                    alert('失败原因不能为空');
                    return false;
                }
                /*if(check_status != 3){
                    alert('是否失败状态未改变');
                    return false;
                }*/
                layer.confirm('确认审核？！', function (index) {

                    $.post('/admin/driver_withdraw/submits', {'id': id, 'driver_id': driver_id,'audit_status': check_status, 'driver_phone': driver_phone, 'error_code': error_code}, function (res) {
                        switch (res['code']) {
                            case 1:
                                layer.msg(res['msg'], {icon: 1});
                                setTimeout(function(){
                                    parent.window.location.reload();
                                },2000);
                                break;
                            default:
                                layer.msg(res['msg'], {icon: 5});
                                break;
                        }
                    }, 'json');
                    layer.close(index);
                });
            })





        });
    </script>

</block>